<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span class="hs-cpp">

#include &quot;containers.h&quot;
</span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  Utils.Containers.Internal.BitQueue</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) David Feuer 2016</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  BSD-style</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- = WARNING</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- This module is considered __internal__.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- The Package Versioning Policy __does not apply__.</span><span>
</span><span id="line-19"></span><span class="hs-comment">--</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- The contents of this module may change __in any way whatsoever__</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- and __without any warning__ between minor versions of this package.</span><span>
</span><span id="line-22"></span><span class="hs-comment">--</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- Authors importing this module are expected to track development</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- closely.</span><span>
</span><span id="line-25"></span><span class="hs-comment">--</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- = Description</span><span>
</span><span id="line-27"></span><span class="hs-comment">--</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- An extremely light-weight, fast, and limited representation of a string of</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- up to (2*WORDSIZE - 2) bits. In fact, there are two representations,</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- misleadingly named bit queue builder and bit queue. The builder supports</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- only `emptyQB`, creating an empty builder, and `snocQB`, enqueueing a bit.</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- The bit queue builder is then turned into a bit queue using `buildQ`, after</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- which bits can be removed one by one using `unconsQ`. If the size limit is</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- exceeded, further operations will silently produce nonsense.</span><span>
</span><span id="line-35"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Utils.Containers.Internal.BitQueue</span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier">BitQueue</span></a></span><span>
</span><span id="line-39"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier">BitQueueB</span></a></span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#emptyQB"><span class="hs-identifier">emptyQB</span></a></span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#snocQB"><span class="hs-identifier">snocQB</span></a></span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#buildQ"><span class="hs-identifier">buildQ</span></a></span><span>
</span><span id="line-43"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#unconsQ"><span class="hs-identifier">unconsQ</span></a></span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#toListQ"><span class="hs-identifier">toListQ</span></a></span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#if !MIN_VERSION_base(4,8,0)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Word</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Word</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitUtil.html"><span class="hs-identifier">Utils.Containers.Internal.BitUtil</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-identifier">shiftLL</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-identifier">shiftRL</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier">wordSize</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator">(.|.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator">(.&amp;.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#testBit"><span class="hs-identifier">testBit</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if MIN_VERSION_base(4,8,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Bits.html#countTrailingZeros"><span class="hs-identifier">countTrailingZeros</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Bits</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">popCount</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if !MIN_VERSION_base(4,8,0)
</span><span class="hs-identifier">countTrailingZeros</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Word</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-60"></span><span class="hs-identifier">countTrailingZeros</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">popCount</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-identifier">x</span><span> </span><span class="hs-operator">.&amp;.</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-identifier">x</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-</span><span> </span><span class="hs-number">1</span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">countTrailingZeros</span><span> </span><span class="hs-pragma">#-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- A bit queue builder. We represent a double word using two words</span><span>
</span><span id="line-65"></span><span class="hs-comment">-- because we don't currently have access to proper double words.</span><span>
</span><span id="line-66"></span><span class="hs-keyword">data</span><span> </span><span id="BitQueueB"><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-var">BitQueueB</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="BQB"><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-var">BQB</span></a></span></span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Word</span></span><span>
</span><span id="line-67"></span><span>                     </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Word</span></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-keyword">newtype</span><span> </span><span id="BitQueue"><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier hs-var">BitQueue</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="BQ"><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQ"><span class="hs-identifier hs-var">BQ</span></a></span></span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span> </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621679158316"><span id="local-6989586621679158318"><span id="local-6989586621679158323"><span class="annot"><span class="annottext">Int -&gt; BitQueue -&gt; ShowS
[BitQueue] -&gt; ShowS
BitQueue -&gt; String
(Int -&gt; BitQueue -&gt; ShowS)
-&gt; (BitQueue -&gt; String) -&gt; ([BitQueue] -&gt; ShowS) -&gt; Show BitQueue
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [BitQueue] -&gt; ShowS
$cshowList :: [BitQueue] -&gt; ShowS
show :: BitQueue -&gt; String
$cshow :: BitQueue -&gt; String
showsPrec :: Int -&gt; BitQueue -&gt; ShowS
$cshowsPrec :: Int -&gt; BitQueue -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-comment">-- Intended for debugging.</span><span>
</span><span id="line-72"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679158310"><span id="local-6989586621679158313"><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-73"></span><span>  </span><span id="local-6989586621679158290"><span class="annot"><span class="annottext">show :: BitQueueB -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var hs-var hs-var hs-var">show</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span id="local-6989586621679158288"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158288"><span class="hs-identifier hs-var">hi</span></a></span></span><span> </span><span id="local-6989586621679158287"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158287"><span class="hs-identifier hs-var">lo</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;BQ&quot;</span></span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-74"></span><span>    </span><span class="annot"><span class="annottext">[Bool] -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Int -&gt; Bool) -&gt; [Int] -&gt; [Bool]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Bool
forall a. Bits a =&gt; a -&gt; Int -&gt; Bool
</span><a href="../../base/src/Data.Bits.html#testBit"><span class="hs-identifier hs-var">testBit</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158288"><span class="hs-identifier hs-var">hi</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span class="hs-glyph">..</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-75"></span><span>            </span><span class="annot"><span class="annottext">[Bool] -&gt; [Bool] -&gt; [Bool]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Bool) -&gt; [Int] -&gt; [Bool]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Bool
forall a. Bits a =&gt; a -&gt; Int -&gt; Bool
</span><a href="../../base/src/Data.Bits.html#testBit"><span class="hs-identifier hs-var">testBit</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158287"><span class="hs-identifier hs-var">lo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span class="hs-glyph">..</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-comment">-- | Create an empty bit queue builder. This is represented as a single guard</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- bit in the most significant position.</span><span>
</span><span id="line-79"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#emptyQB"><span class="hs-identifier hs-type">emptyQB</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span>
</span><span id="line-80"></span><span id="emptyQB"><span class="annot"><span class="annottext">emptyQB :: BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#emptyQB"><span class="hs-identifier hs-var hs-var">emptyQB</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-var">BQB</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">0</span></span><span>
</span><span id="line-81"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#emptyQB"><span class="hs-pragma hs-type">emptyQB</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-82"></span><span>
</span><span id="line-83"></span><span class="hs-comment">-- Shift the double word to the right by one bit.</span><span>
</span><span id="line-84"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#shiftQBR1"><span class="hs-identifier hs-type">shiftQBR1</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span>
</span><span id="line-85"></span><span id="shiftQBR1"><span class="annot"><span class="annottext">shiftQBR1 :: BitQueueB -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#shiftQBR1"><span class="hs-identifier hs-var hs-var">shiftQBR1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span id="local-6989586621679158285"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158285"><span class="hs-identifier hs-var">hi</span></a></span></span><span> </span><span id="local-6989586621679158284"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158284"><span class="hs-identifier hs-var">lo</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-var">BQB</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158283"><span class="hs-identifier hs-var">hi'</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158282"><span class="hs-identifier hs-var">lo'</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-86"></span><span>  </span><span id="local-6989586621679158282"><span class="annot"><span class="annottext">lo' :: Word
</span><a href="#local-6989586621679158282"><span class="hs-identifier hs-var hs-var">lo'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158284"><span class="hs-identifier hs-var">lo</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158285"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span>  </span><span id="local-6989586621679158283"><span class="annot"><span class="annottext">hi' :: Word
</span><a href="#local-6989586621679158283"><span class="hs-identifier hs-var hs-var">hi'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158285"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-88"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#shiftQBR1"><span class="hs-pragma hs-type">shiftQBR1</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-89"></span><span>
</span><span id="line-90"></span><span class="hs-comment">-- | Enqueue a bit. This works by shifting the queue right one bit,</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- then setting the most significant bit as requested.</span><span>
</span><span id="line-92"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#snocQB"><span class="hs-pragma hs-type">snocQB</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-93"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#snocQB"><span class="hs-identifier hs-type">snocQB</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span>
</span><span id="line-94"></span><span id="snocQB"><span class="annot"><span class="annottext">snocQB :: BitQueueB -&gt; Bool -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#snocQB"><span class="hs-identifier hs-var hs-var">snocQB</span></a></span></span><span> </span><span id="local-6989586621679158278"><span class="annot"><span class="annottext">BitQueueB
</span><a href="#local-6989586621679158278"><span class="hs-identifier hs-var">bq</span></a></span></span><span> </span><span id="local-6989586621679158277"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679158277"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BitQueueB -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#shiftQBR1"><span class="hs-identifier hs-var">shiftQBR1</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueueB
</span><a href="#local-6989586621679158278"><span class="hs-identifier hs-var">bq</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-95"></span><span>  </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span id="local-6989586621679158276"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158276"><span class="hs-identifier hs-var">hi</span></a></span></span><span> </span><span id="local-6989586621679158275"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158275"><span class="hs-identifier hs-var">lo</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-var">BQB</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158276"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Word
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="../../base/src/GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679158277"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158275"><span class="hs-identifier hs-var">lo</span></a></span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span class="hs-comment">-- | Convert a bit queue builder to a bit queue. This shifts in a new</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- guard bit on the left, and shifts right until the old guard bit falls</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- off.</span><span>
</span><span id="line-100"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#buildQ"><span class="hs-pragma hs-type">buildQ</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-101"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#buildQ"><span class="hs-identifier hs-type">buildQ</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueueB"><span class="hs-identifier hs-type">BitQueueB</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier hs-type">BitQueue</span></a></span><span>
</span><span id="line-102"></span><span id="buildQ"><span class="annot"><span class="annottext">buildQ :: BitQueueB -&gt; BitQueue
</span><a href="Utils.Containers.Internal.BitQueue.html#buildQ"><span class="hs-identifier hs-var hs-var">buildQ</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span id="local-6989586621679158273"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158273"><span class="hs-identifier hs-var">hi</span></a></span></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BitQueueB -&gt; BitQueue
</span><a href="Utils.Containers.Internal.BitQueue.html#BQ"><span class="hs-identifier hs-var">BQ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-var">BQB</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158272"><span class="hs-identifier hs-var">lo'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-103"></span><span>  </span><span id="local-6989586621679158269"><span class="annot"><span class="annottext">zeros :: Int
</span><a href="#local-6989586621679158269"><span class="hs-identifier hs-var hs-var">zeros</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int
forall b. FiniteBits b =&gt; b -&gt; Int
</span><a href="../../base/src/Data.Bits.html#countTrailingZeros"><span class="hs-identifier hs-var">countTrailingZeros</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158273"><span class="hs-identifier hs-var">hi</span></a></span><span>
</span><span id="line-104"></span><span>  </span><span id="local-6989586621679158272"><span class="annot"><span class="annottext">lo' :: Word
</span><a href="#local-6989586621679158272"><span class="hs-identifier hs-var hs-var">lo'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158273"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679158269"><span class="hs-identifier hs-var">zeros</span></a></span><span>
</span><span id="line-105"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#buildQ"><span class="hs-identifier hs-var">buildQ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span id="local-6989586621679158265"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158265"><span class="hs-identifier hs-var">hi</span></a></span></span><span> </span><span id="local-6989586621679158264"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158264"><span class="hs-identifier hs-var">lo</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BitQueueB -&gt; BitQueue
</span><a href="Utils.Containers.Internal.BitQueue.html#BQ"><span class="hs-identifier hs-var">BQ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-var">BQB</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158263"><span class="hs-identifier hs-var">hi'</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158262"><span class="hs-identifier hs-var">lo'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-106"></span><span>  </span><span id="local-6989586621679158260"><span class="annot"><span class="annottext">zeros :: Int
</span><a href="#local-6989586621679158260"><span class="hs-identifier hs-var hs-var">zeros</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int
forall b. FiniteBits b =&gt; b -&gt; Int
</span><a href="../../base/src/Data.Bits.html#countTrailingZeros"><span class="hs-identifier hs-var">countTrailingZeros</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158264"><span class="hs-identifier hs-var">lo</span></a></span><span>
</span><span id="line-107"></span><span>  </span><span id="local-6989586621679158256"><span class="annot"><span class="annottext">lo1 :: Word
</span><a href="#local-6989586621679158256"><span class="hs-identifier hs-var hs-var">lo1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158264"><span class="hs-identifier hs-var">lo</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158265"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>  </span><span id="local-6989586621679158252"><span class="annot"><span class="annottext">hi1 :: Word
</span><a href="#local-6989586621679158252"><span class="hs-identifier hs-var hs-var">hi1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158265"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>  </span><span id="local-6989586621679158262"><span class="annot"><span class="annottext">lo' :: Word
</span><a href="#local-6989586621679158262"><span class="hs-identifier hs-var hs-var">lo'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158256"><span class="hs-identifier hs-var">lo1</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679158260"><span class="hs-identifier hs-var">zeros</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158252"><span class="hs-identifier hs-var">hi1</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftLL"><span class="hs-operator hs-var">`shiftLL`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="Utils.Containers.Internal.BitUtil.html#wordSize"><span class="hs-identifier hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679158260"><span class="hs-identifier hs-var">zeros</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>  </span><span id="local-6989586621679158263"><span class="annot"><span class="annottext">hi' :: Word
</span><a href="#local-6989586621679158263"><span class="hs-identifier hs-var hs-var">hi'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158252"><span class="hs-identifier hs-var">hi1</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Int -&gt; Word
</span><a href="Utils.Containers.Internal.BitUtil.html#shiftRL"><span class="hs-operator hs-var">`shiftRL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679158260"><span class="hs-identifier hs-var">zeros</span></a></span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- Test if the queue is empty, which occurs when theres</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- nothing left but a guard bit in the least significant</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- place.</span><span>
</span><span id="line-115"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#nullQ"><span class="hs-identifier hs-type">nullQ</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier hs-type">BitQueue</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-116"></span><span id="nullQ"><span class="annot"><span class="annottext">nullQ :: BitQueue -&gt; Bool
</span><a href="Utils.Containers.Internal.BitQueue.html#nullQ"><span class="hs-identifier hs-var hs-var">nullQ</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQ"><span class="hs-identifier hs-type">BQ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-117"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#nullQ"><span class="hs-identifier hs-var">nullQ</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueue
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-118"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#nullQ"><span class="hs-pragma hs-type">nullQ</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-comment">-- | Dequeue an element, or discover the queue is empty.</span><span>
</span><span id="line-121"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#unconsQ"><span class="hs-identifier hs-type">unconsQ</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier hs-type">BitQueue</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier hs-type">BitQueue</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span id="unconsQ"><span class="annot"><span class="annottext">unconsQ :: BitQueue -&gt; Maybe (Bool, BitQueue)
</span><a href="Utils.Containers.Internal.BitQueue.html#unconsQ"><span class="hs-identifier hs-var hs-var">unconsQ</span></a></span></span><span> </span><span id="local-6989586621679158248"><span class="annot"><span class="annottext">BitQueue
</span><a href="#local-6989586621679158248"><span class="hs-identifier hs-var">q</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">BitQueue -&gt; Bool
</span><a href="Utils.Containers.Internal.BitQueue.html#nullQ"><span class="hs-identifier hs-var">nullQ</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueue
</span><a href="#local-6989586621679158248"><span class="hs-identifier hs-var">q</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Bool, BitQueue)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-123"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#unconsQ"><span class="hs-identifier hs-var">unconsQ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQ"><span class="hs-identifier hs-type">BQ</span></a></span><span> </span><span id="local-6989586621679158247"><span class="annot"><span class="annottext">bq :: BitQueueB
</span><a href="#local-6989586621679158247"><span class="hs-identifier hs-var">bq</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BQB"><span class="hs-identifier hs-type">BQB</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679158246"><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158246"><span class="hs-identifier hs-var">lo</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, BitQueue) -&gt; Maybe (Bool, BitQueue)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679158245"><span class="hs-identifier hs-var">hd</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BitQueueB -&gt; BitQueue
</span><a href="Utils.Containers.Internal.BitQueue.html#BQ"><span class="hs-identifier hs-var">BQ</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueueB
</span><a href="#local-6989586621679158244"><span class="hs-identifier hs-var">tl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-124"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-125"></span><span>    </span><span class="hs-glyph">!</span><span id="local-6989586621679158245"><span class="annot"><span class="annottext">hd :: Bool
</span><a href="#local-6989586621679158245"><span class="hs-identifier hs-var hs-var">hd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word
</span><a href="#local-6989586621679158246"><span class="hs-identifier hs-var">lo</span></a></span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Word
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word -&gt; Word -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Word
</span><span class="hs-number">0</span></span><span>
</span><span id="line-126"></span><span>    </span><span class="hs-glyph">!</span><span id="local-6989586621679158244"><span class="annot"><span class="annottext">tl :: BitQueueB
</span><a href="#local-6989586621679158244"><span class="hs-identifier hs-var hs-var">tl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BitQueueB -&gt; BitQueueB
</span><a href="Utils.Containers.Internal.BitQueue.html#shiftQBR1"><span class="hs-identifier hs-var">shiftQBR1</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueueB
</span><a href="#local-6989586621679158247"><span class="hs-identifier hs-var">bq</span></a></span><span>
</span><span id="line-127"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#unconsQ"><span class="hs-pragma hs-type">unconsQ</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="hs-comment">-- | Convert a bit queue to a list of bits by unconsing.</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- This is used to test that the queue functions properly.</span><span>
</span><span id="line-131"></span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#toListQ"><span class="hs-identifier hs-type">toListQ</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.BitQueue.html#BitQueue"><span class="hs-identifier hs-type">BitQueue</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">]</span><span>
</span><span id="line-132"></span><span id="toListQ"><span class="annot"><span class="annottext">toListQ :: BitQueue -&gt; [Bool]
</span><a href="Utils.Containers.Internal.BitQueue.html#toListQ"><span class="hs-identifier hs-var hs-var">toListQ</span></a></span></span><span> </span><span id="local-6989586621679158238"><span class="annot"><span class="annottext">BitQueue
</span><a href="#local-6989586621679158238"><span class="hs-identifier hs-var">bq</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BitQueue -&gt; Maybe (Bool, BitQueue)
</span><a href="Utils.Containers.Internal.BitQueue.html#unconsQ"><span class="hs-identifier hs-var">unconsQ</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueue
</span><a href="#local-6989586621679158238"><span class="hs-identifier hs-var">bq</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-133"></span><span>      </span><span class="annot"><span class="annottext">Maybe (Bool, BitQueue)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-134"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679158237"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679158237"><span class="hs-identifier hs-var">hd</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679158236"><span class="annot"><span class="annottext">BitQueue
</span><a href="#local-6989586621679158236"><span class="hs-identifier hs-var">tl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679158237"><span class="hs-identifier hs-var">hd</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [Bool] -&gt; [Bool]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">BitQueue -&gt; [Bool]
</span><a href="Utils.Containers.Internal.BitQueue.html#toListQ"><span class="hs-identifier hs-var">toListQ</span></a></span><span> </span><span class="annot"><span class="annottext">BitQueue
</span><a href="#local-6989586621679158236"><span class="hs-identifier hs-var">tl</span></a></span><span>
</span><span id="line-135"></span></pre></body></html>